package com.zenith.article.controller;

import com.zenith.article.po.domain.ArtTopic;
import com.zenith.article.po.dto.ArtTopicDTO;
import com.zenith.article.service.ArtTopicService;
import com.zenith.common.annotation.request.SecurePostMapping;
import com.zenith.common.result.Result;
import com.zenith.common.result.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文章专题控制器
 *
 * @author zenith
 * @since 2025-08-29
 */
@RestController
@RequestMapping("/api/article/topic")
@Tag(name = "文章专题管理", description = "文章专题相关接口")
public class ArtTopicController {

    @Autowired
    private ArtTopicService artTopicService;

    /**
     * 分页查询文章专题
     */
    @Operation(summary = "分页查询文章专题")
    @SecurePostMapping("/getArtTopicPage")
    public Result<PageResult<ArtTopic>> getArtTopicPage(ArtTopicDTO query) {
        PageResult<ArtTopic> pageResult = artTopicService.getArtTopicPage(query);
        return Result.success(pageResult);
    }

    /**
     * 创建文章专题
     */
    @Operation(summary = "创建文章专题")
    @SecurePostMapping("/createArtTopic")
    public Result<Boolean> createArtTopic(@RequestBody ArtTopicDTO topicDTO) {
        boolean result = artTopicService.createArtTopic(topicDTO);
        return Result.success(result);
    }

    /**
     * 更新文章专题
     */
    @Operation(summary = "更新文章专题")
    @SecurePostMapping("/updateArtTopic")
    public Result<Boolean> updateArtTopic(@RequestBody ArtTopicDTO topicDTO) {
        boolean result = artTopicService.updateArtTopic(topicDTO);
        return Result.success(result);
    }

    /**
     * 删除文章专题
     */
    @Operation(summary = "删除文章专题")
    @SecurePostMapping("/deleteArtTopic/{id}")
    public Result<Boolean> deleteArtTopic(@PathVariable Long id) {
        boolean result = artTopicService.deleteArtTopic(id);
        return Result.success(result);
    }
}